package com.song.invoicing.mapper;

import com.github.pagehelper.Page;
import com.song.invoicing.pojo.dao.Product;
import com.song.invoicing.pojo.dao.PurchaseRecord;
import com.song.invoicing.pojo.dto.PurchaseQueryDTO;
import com.song.invoicing.pojo.dto.PurchaseRecordUpdateStatusDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface PurchaseRecordMapper {


    Page<PurchaseRecord> getPurchaseRecords(PurchaseQueryDTO purchaseQueryDTO);
    @Update("update invoicing.purchase_records set purchase_status=#{purchaseStatus} where purchase_id=#{purchaseId}")
    void updateStatus(PurchaseRecordUpdateStatusDTO purchaseRecordUpdateStatusDTO);

    void addPurchaseRecord(PurchaseRecord purchaseRecord);

    void updatePurchaseRecord(PurchaseRecord purchaseRecord);
   @Select("select product_name , product_unit ,unit_price as purchasePrice,  purchase_quantity as stock  from invoicing.purchase_records where purchase_id=#{purchaseId}")
    Product getPurchaseRecord(Integer purchaseId);
}
